
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.Scanner; 

/**
 * This class practices using a GUI 
 * 
 * @author (your name) 
 * @version (a version number)
 */
public class GuiIntroToImages extends BorlandBase
{
    //We have 3 swing components that we must declare up here, so every method has access to them
    BTextField xLocation = new BTextField(20);
    JButton showButton= new JButton ("Show");
    JButton hideButton = new JButton ("Hide"); 

    /**
     * This method will be called one time at the beginning of your applet/program
     */
    public void initialize()
    {
        setWidth(700);
        setHeight(700);
        setBackgroundColor(Color.blue);
        setBackgroundImage("pipe.png",200,200);
        //if the image was big enough you could do just set setBackgroundImage("pipe.png"); without specifying x,y
        
        //items need to be added after background stuff.
        addItem(xLocation);
        addItem(showButton);
        addItem(hideButton);  
    }

    /**
     * This method gets called if the button is pressed
     * c  is the component (button usually) that was pressed
     */
    public void buttonPressed (Component c)
    { 
        echo ("action being performed");  //this is just like system.out.println - but shorter
        if (c == showButton)
        {            
              int x=xLocation.getInt();      
              drawImage("mario.png",x,50);           
        }
        if (c == hideButton)
        {
            clearScreen();
            playSound("sound.wav");            
        }
    }

    /**
     * This method if you would like to do drawing on your screen
     */
    public void paintScreen (Graphics g)
    {       
    }


    public static void runAsApplet()
    {
        try{  BorlandBase.runAsApplet((BorlandBase)(new Object() { }.getClass().getEnclosingClass().newInstance()));  }
        catch (Exception e){e.printStackTrace();}
    }

    public static void main(String[] args) {
        try{  BorlandBase.main((BorlandBase)(new Object() { }.getClass().getEnclosingClass().newInstance()));  }
        catch (Exception e){e.printStackTrace();}
    }

}
